package com.pk.springbootsy1.dto;


import com.pk.springbootsy1.entity.TEquipment;
import com.pk.springbootsy1.entity.TUser;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@Schema(name = "TEquipmentDto", description = "设备信息")
public class TEquipmentDto {

    @Schema(description = "设备id")
    private Integer id;
    @Schema(description = "设备名称")
    private String name;
    @Schema(description = "设备描述")
    private String description;
    @Schema(description = "设备编号")
    private String code;
    @Schema(description = "设备添加时间")
    private Date addTime;
    @Schema(description = "设备价格")
    private String price;
    @Schema(description = "设备存放地点")
    private String place;
    @Schema(description = "设备所属用户id")
    private Integer userId;

    public static List<TEquipmentDto> convert(List<TEquipment> equipments) {
        List<TEquipmentDto> equipmentDtos = new ArrayList<>();
        equipments.stream().forEach(s -> {
            TEquipmentDto equipmentDto = new TEquipmentDto();
            BeanUtil.copyProperties(s, equipmentDto);
            equipmentDtos.add(equipmentDto);
        });
        return equipmentDtos;
    }
    public static TEquipmentDto convert(TEquipment equipment) {
        TEquipmentDto equipmentDto = new TEquipmentDto();
        BeanUtil.copyProperties(equipment, equipmentDto);
        return equipmentDto;
    }
}